package com.mxpio.erp.common.plm.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

/**
 *  任务执行日志
 * @author qb
 * @since 2024-2-21
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_PLM_PROJECT_TASK_EXECUTION_LOG")
@Schema(description="任务执行日志")
public class ProjectTaskExecutionLog extends BaseEntity {

    private static final long serialVersionUID=1L;
    /**主键*/
    @Id
    @Generator
    @Column(name = "ID_", updatable = false)
    @Schema(description = "主键")
    private String id;

    @Column(name = "TASK_CODE_")
    @Schema(description = "任务编码")
    private String taskCode;

    @Column(name = "PRO_CODE_")
    @Schema(description = "项目编码")
    private String proCode;

    @Column(name = "LOG_TYPE_")
    @Schema(description = "日志类型")
    @Dict(dicCode = "ERP_TASK_LOG_TYPE")
    private String logType;

    @Column(name = "APPLICANT_")
    @Schema(description = "申请人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String applicant;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "APPLY_TIME_")
    @Schema(description = "申请时间")
    private Date applyTime;

    @Column(name = "APPLY_DESC_",columnDefinition="TEXT")
    @Schema(description = "申请描述")
    private String applyDesc;

    @Column(name = "HEAD_")
    @Schema(description = "负责人")//项目审核的负责人，可多个
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String head;

    @Column(name = "HEAD_TASK_")
    @Schema(description = "任务负责人")//
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String headTask;

    @Column(name = "AUDIT_STATUS_")
    @Schema(description = "审核状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String auditStatus;

    @Column(name = "AUDIT_OPINION_")
    @Schema(description = "审核意见")
    @Dict(dicCode = "MB_SYSTEM_YES_NO")
    private String auditOpinion;

    @Column(name = "AUDIT_OPINION_DESC_",columnDefinition="TEXT")
    @Schema(description = "审核意见描述")
    private String auditOpinionDesc;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name = "AUDIT_TIME_")
    @Schema(description = "审核时间")
    private Date auditTime;

    @Column(name = "AUDIT_PERSON_")
    @Schema(description = "审核人")//
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String auditPerson;

    /**
     * 原任务进度
     */
    @Column(name = "ORI_PROGRESS_")
    @Schema(description = "原任务进度")
    private BigDecimal oriProgress;

    /**
     * 任务进度
     */
    @Column(name = "PROGRESS_")
    @Schema(description = "任务进度")
    private BigDecimal progress;

    /**
     * 任务问题ID
     */
    @Column(name = "PROBLEM_ID_")
    @Schema(description = "任务问题ID")
    private String problemId;

    @Column(name = "NORMAL_WORK_TIME_")
    @Schema(description = "正常工时")
    private BigDecimal normalWorkTime;

    @Column(name = "OVERTIME_WORK_TIME_")
    @Schema(description = "加班工时")
    private BigDecimal overtimeWorkTime;

    @Column(name = "SUBSTANCE_",columnDefinition="TEXT")
    @Schema(description = "上报内容")
    private String substance;

    /**实际开始日期*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "实际开始日期")
    private Date actualStartTime;
    /**实际结束时间*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "实际结束日期")
    private Date actualEndTime;

    /**实际工期*/
    @Schema(description = "实际工期（天）")
    private BigDecimal actualDuration;

    /**审批状态*/
    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审批状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String bpmnStatus;

    /**审批实例ID*/
    @Column(name = "PROCESS_INSTANCE_ID_")
    @Schema(description = "审批实例ID")
    private String processInstanceId;

    @Column(name = "IS_AUDIT_END_")
    @Schema(description = "是否是工作流")
    @Dict(dicCode = "MB_SYSTEM_YES_NO")//1:是；0:否
    private String isAuditEnd;


    /**项目名称*/
    @Column(name = "PRO_NAME_")
    @Schema(description = "项目名称")
    private String proName;

    /**项目经理*/
    @Column(name = "PRO_LEADER_")
    @Schema(description = "项目经理")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String proLeader;

    /**项目状态*/
    @Column(name = "PRO_STATUS_")
    @Schema(description = "项目状态")
    @Dict(dicCode = "ERP_PROJECT_INFO_PROSTATUS")
    private String proStatus;

    @Column(name = "TASK_NAME_")
    @Schema(description = "任务名称")
    private String taskName;

    /**
     * 任务状态：1-正常、0-延期
     */
    @Column(name = "TASK_STATUS_")
    @Schema(description = "任务状态")
    @Dict(dicCode = "ERP_PROJECT_INFO_STATUS")
    private String taskStatus;

    @Column(name = "TASK_TYPE_")
    @Schema(description = "任务类型")
    @Dict(dicCode = "ERP_PLM_PROJECT_TASK_TYPE")//10 项目任务 20 风险预案
    private String taskType;

    @Column(name = "PARENT_TASK_CODE_")
    @Schema(description = "父级任务编码")
    private String parentTaskCode;

    @Column(name = "PARENT_TASK_NAME_")
    @Schema(description = "父级任务名称")
    private String parentTaskName;

    @Column(name = "PARENT_HEAD_")
    @Schema(description = "父级负责人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String parentHead;

    /**
     * 任务执行状态：10-待启动，20-执行中，30-已关闭，40-已完成
     */
    @Column(name = "EXECUTION_STATUS_")
    @Schema(description = "执行状态")
    @Dict(dicCode = "ERP_PLM_TASK_EXECUTION_STATUS")
    private String executionStatus;

    @Column(name = "MILESTONE_")
    @Schema(description = "是否里程碑")
    @Dict(dicCode = "MB_SYSTEM_YES_NO")//1:是；0:否
    private String milestone;

    @Column(name = "TASK_MEMBERS_")
    @Schema(description = "任务成员")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String taskMembers;



    /**计划开始日期*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "计划开始日期")
    @Column(name = "PLAN_START_TIME_")
    private java.util.Date planStartTime;
    /**计划结束时间*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "计划结束日期")
    @Column(name = "PLAN_END_TIME_")
    private java.util.Date planEndTime;

    /**工期*/
    @Column(name = "DURATION_")
    @Schema(description = "工期（天）")
    private BigDecimal duration;

    @Column(name = "TASK_LINK_")
    @Schema(description = "前后置任务关系")
    @Dict(dicCode = "ERP_PROJECT_TASKS_LINKS")
    private String taskLink;

    @Column(name = "BEFORE_TASK_")
    @Schema(description = "前置任务")
    private String beforeTask;

    @Column(name = "AFTER_TASK_")
    @Schema(description = "后置任务")
    private String afterTask;

    @Column(name = "DESC_",columnDefinition="TEXT")
    @Schema(description = "任务描述")
    private String desc;

    @Column(name = "NOTES_")
    @Schema(description = "备注")
    private String notes;

    @Column(name = "NUMBER_")
    @Schema(description = "任务顺序")
    private Integer number;

    @Column(name = "LEVEL_")
    @Schema(description = "任务层级")
    private String level;


    @Column(name = "APPROVAL_PLAN_")
    @Dict(dicCode = "ERP_PLM_APPROVAL_PLAN")
    @Schema(description = "审批方案")
    private Integer approvalPlan;

    @Column(name = "TASK_TEMPLATE_CODE_")
    @Schema(description = "当为模版时的任务编码")
    private String taskTemplateCode;

    @Column(name = "WORKFLOW_ID_")
    @Schema(description = "工作流ID")//当任务走工作流的时候，应有工作流的ID
    private String workflowId;

}
